<?php

/**
 * This is the model class for table "gn_payouts".
 *
 * The followings are the available columns in table 'gn_payouts':
 * @property double $payout_id
 * @property integer $member_id
 * @property integer $year
 * @property integer $week_no
 * @property integer $bv_personal
 * @property integer $bv_left
 * @property integer $bv_right
 * @property integer $bv_left_carryover
 * @property integer $bv_right_carryover
 * @property integer $bv_match
 * @property double $payout
 * @property string $status
 * @property string $dt_created
 */
class Payouts extends CActiveRecord
{
	
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Payouts the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'gn_payouts';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('member_id, year, week_no, bv_personal, status, dt_created', 'required'),
			array('member_id, year, week_no, bv_personal, bv_left, bv_right, bv_left_carryover, bv_right_carryover, bv_match', 'numerical', 'integerOnly'=>true),
			array('payout', 'numerical'),
			array('status', 'length', 'max'=>8),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('payout_id, member_id, year, week_no, bv_personal, bv_left, bv_right, bv_left_carryover, bv_right_carryover, bv_match, payout, status, dt_created', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		
		return array(
		   //'Members' => array(self::BELONGS_TO, 'Members', 'member_id'),
		);
		
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'payout_id' => 'Payout',
			'member_id' => 'Member',
			'year' => 'Year',
			'week_no' => 'Week No',
			'bv_personal' => 'Bv Personal',
			'bv_left' => 'Bv Left',
			'bv_right' => 'Bv Right',
			'bv_left_carryover' => 'Bv Left Carryover',
			'bv_right_carryover' => 'Bv Right Carryover',
			'bv_match' => 'Bv Match',
			'payout' => 'Payout',
			'status' => 'Status',
			'dt_created' => 'Dt Created',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;
        //$criteria->with = array( 'Members.first_name', 'Members.last_name');
        
        
		$criteria->compare('payout_id',$this->payout_id);
		$criteria->compare('member_id',$this->member_id);
		$criteria->compare('year',$this->year);
		$criteria->compare('week_no',$this->week_no);
		$criteria->compare('bv_personal',$this->bv_personal);
		$criteria->compare('bv_left',$this->bv_left);
		$criteria->compare('bv_right',$this->bv_right);
		$criteria->compare('bv_left_carryover',$this->bv_left_carryover);
		$criteria->compare('bv_right_carryover',$this->bv_right_carryover);
		$criteria->compare('bv_match',$this->bv_match);
		$criteria->compare('payout',$this->payout);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('dt_created',$this->dt_created,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}